<#include "layout/application.ftl"/>

<@application>
<div class="panel-heading">
    <span class="panel-title"><h4>配置项</h4></span>
    <span>
    <button type="button" class="btn btn-primary" onclick="showSetWindow(true)">新增</button>
    </span>
</div>
<table class="table table-bordered">
    <thead>
    <tr>
        <th>键</th>
        <th>值</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
        <#list configs?keys as key>
        <tr>
            <td>${key}</td>
            <td>${configs[key]}</td>
            <td>
                <button type="button" class="btn btn-link" onclick="updateConfig('${ctx}/api/get/${active}/${key}')">编辑</button>
            </td>
        </tr>
        </#list>

    </tbody>
</table>
<div id="settings_window" class="modal hide fade in" style="display:none;">
    <div class="modal-header">
        <a class="close" data-dismiss="modal" onclick="showSetWindow(false)">X</a>

        <h3>设置</h3>
    </div>
    <div class="modal-body">
        <form class="form-signin" accept-charset="UTF-8" method="post" id="settings-form">
            <div class="form-group">
                <label class="col-sm-2 control-label" for="name">键</label>

                <div class="col-lg-8">
                    <input class="form-control" id="name" name="name" type="text" style="width: 515px"/>
                </div>

                <label class="col-sm-2 control-label" for="value">值</label>
                <div class="col-lg-8">
                    <textarea class="form-control" id="value" name="value" rows="5" style="width: 515px"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="submitConfig('${ctx}/api/save/${active}')">保存
                </button>
                <button type="button" class="btn btn-default" onclick="showSetWindow(false)">取消</button>
            </div>
        </form>
    </div>

</div>

<div id="update_window" class="modal hide fade in" style="display:none;">
    <div class="modal-header">
        <a class="close" data-dismiss="modal" onclick="showSetWindow(false)">X</a>

        <h3>设置</h3>
    </div>
    <div class="modal-body">
        <form class="form-signin" accept-charset="UTF-8" method="post" id="update-form">
            <div class="form-group">
                <label class="col-sm-2 control-label" for="update_window_name">键</label>

                <div class="col-lg-8">
                    <input class="form-control" id="update_window_name" name="update_window_name" type="text" style="width: 515px"/>
                </div>

                <label class="col-sm-2 control-label" for="update_window_value">值</label>
                <div class="col-lg-8">
                    <textarea class="form-control" id="update_window_value" name="update_window_value" rows="5" style="width: 515px"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="submitUpdateConfig('${ctx}/api/update/${active}')">保存
                </button>
                <button type="button" class="btn btn-default" onclick="showUpdateWindow(false)">取消</button>
            </div>
        </form>
    </div>

</div>

<div class="alert alert-block hide" id="warning-block">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <h4>Warning!</h4>Best check yo self, you're not...
</div>

<script src="../../assets/js/settings.js"></script>
</@application>